// @ts-ignore
import { request } from "./request";
const nextApi = {

    // ------------------------ 用户登录 ----------------
    checkCode: () => {
        return request<{ captcha: string }>({
            url: '/captchaImage',
            method: 'get',
        })
    },
    userLogin: (data: { password: string; name: string; code: string }) => {
        return request({
            data,
            url: '/jsAccount/pcLogin',
            method: 'post',
        })
    },

    getUserInfo: (token: string) => {
        const params: any = {
            url: '/atPcUser/findLoginUserInfo',
            method: 'get',
            headers: { token }
        }
        return request(params)
    },
    changePassword: (data: any) => {
        return request({
            data,
            url: '/atFrontUser/updatePersonageInfo',
            method: 'put',
        })
    },
    // ------------------------ 图片上传 ----------------
    uploadImage: (data: any) => {
        const params: any = {
            data,
            url: '/file/uploadImage',
            method: 'post',
        }
        // if (process.env.NODE_ENV === 'development') {
        //     params.baseURL = 'https://zyykjcgzhxt.cdutcm.edu.cn/api/'
        // }
        return request(params)
    },
    //-------------------用户和权限相关----------------------------
    getAccountList: (params: any) => {
        return request({
            params,
            url: '/jsAccount/findPcAccountByCondition',
            method: 'get',
        })
    },
    getAccountDetail: (id: string) => {
        return request({
            params: { userId: id },
            url: '/jsAccount/findPcUserByPcUserId',
            method: 'get',
        })
    },
    editAccount: (data: any) => {
        return request({
            data,
            url: '/jsAccount/addPcAccount',
            method: 'post',
        })
    },
    updateAccount: (data: any) => {
        return request({
            data,
            url: '/jsAccount/updatePcAccountDetail',
            method: 'put',
        })
    },
    deleteAccount: (id: string) => {
        return request({
            url: `/jsAccount/removePcUserById/${id}`,
            method: 'delete',
        })
    },
    editPermissions: (data: any) => {
        return request({
            data,
            url: '/jsResource/giveDepartmentAndUserAddResource',
            method: 'post',
        })
    },
    getPermissionsById: (params: { organizationId?: string; userId?: string }) => {
        return request({
            params,
            url: '/jsResource/findResourceByDepartmentIdAndUserId',
            method: 'get',
        })
    },
    getOrganizationList: (id?: string) => {
        return request({
            params: { id },
            url: '/jsOrganization/findUserdataByOrganizationId',
            method: 'get',
        })
    },
    editOrganization: (data: any) => {
        return request({
            data,
            url: '/jsOrganization/addOrganization',
            method: 'post',
        })
    },
    deleteOrganization: (id: string) => {
        return request({
            url: `/jsOrganization/removeOrganization/${id}`,
            method: 'delete',
        })
    },

    getVisitStatisticsByTimeRange: () => {
        return request({
            url: '/jsDataStatistics/getVisitStatisticsByTimeRange',
            method: 'get',
        })
    },
    getVisitTrend: () => {
        return request({
            url: '/jsDataStatistics/getVisitTrend',
            method: 'get',
        })
    },
    getVisitStatisticsByInstitutionType: () => {
        return request({
            url: '/jsDataStatistics/getVisitStatisticsByInstitutionType',
            method: 'get',
        })
    },
    getVisitRankingByStore: () => {
        return request({
            url: '/jsDataStatistics/getVisitRankingByStore',
            method: 'get',
        })
    },
    getVisitAndConsumptionTrend: () => {
        return request({
            url: '/jsDataStatistics/getVisitAndConsumptionTrend',
            method: 'get',
        })
    },
    getConsumptionSourceStatistics: () => {
        return request({
            url: '/jsDataStatistics/getConsumptionSourceStatistics',
            method: 'get',
        })
    },
    getConsumptionByType: (type:string) => {
        return request({
            params:{type},
            url: '/jsDataStatistics/getConsumptionByType',
            method: 'get',
        })
    },
}
export default nextApi
